package com.rzj.sys_lab_assistant.service.impl;

import com.rzj.sys_lab_assistant.dao.StudentMapper;
import com.rzj.sys_lab_assistant.entity.Student;
import com.rzj.sys_lab_assistant.service.IStudentService;
import com.rzj.sys_lab_assistant.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sys_lab_assistant
 * @description:
 * @author: 作者
 * @create: 2021-06-29 17:14
 */
@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired
    StudentMapper studentMapper;

    TimeUtils timeUtils;

    @Override
    public List<Student> listStudents() {
        return studentMapper.listStudents();
    }

    @Override
    public Student getStudentById(String studentNo) {
        return studentMapper.getStudentById(studentNo);
    }

    @Override
    public int saveStudent(Student student) {
        student.setCreateTime(timeUtils.getTime());
        student.setModifyTime(timeUtils.getTime());

        return studentMapper.saveStudent(student);
    }

    @Override
    public int updateStudent(Student student) {
        student.setModifyTime(timeUtils.getTime());
        return studentMapper.updateStudent(student);
    }

    @Override
    public int deleteStudent(String studentNo) {
        return studentMapper.deleteStudent(studentNo);
    }

}
